import { BattleObj } from '../BattleObj';
import { SkillBase } from './SkillBase';

export class SkillManager {
  private skills = new Map<number, SkillBase>();

  constructor(private owner: BattleObj) {}

  initSkills() {
    // 初始化时绑定技能事件
    this.skills.forEach(skill => {
      if (skill.isPassive) {
        skill.registerEvents();
      }
    });
  }

  addSkill(skill: SkillBase) {
    this.skills.set(skill.id, skill);
    if (skill.isPassive) {
      skill.registerEvents();
    }
  }

  getSkill(id: number): SkillBase | undefined {
    return this.skills.get(id);
  }
}
